<template>
    <div>
<h1>病房信息列表展示</h1>
科室
<select v-model="can.ksid">
                <option  :value="0">请选择</option>
                <option v-for="a in ba" :value="a.kId">{{ a.ksName }}</option>
            </select>


病房名称
<input type="text" v-model="can.name">  

<input type="button" value="查询" @click="cha">
<table class="table">
<thead>
    <tr>
        <td>病房号</td>
        <td>所属科室</td>
        <td>床位数</td>
        <td>状态</td>
        <td>空床位</td>
        <td>创建时间</td>
        <td>操作</td>
       
    </tr>
</thead>

<tbody>
     <tr v-for="a in da">
        <td>{{a.fangHao}}</td>
        <td>{{a.ksName}}</td>
        <td>{{a.shuLiang}}</td>
        <td>{{a.ztName}}</td>
        <td>{{a.kong}}</td>
        <td>{{a.fangCreateTime}}</td>
        <td>
            <input type="button" :value="a.ztName=='启用'?'维修':'启用'"    @click="gai(a.bingId)">
        </td>
       
    </tr>
</tbody>
</table>
    </div>
</template>

<script setup lang="ts">
import axios from 'axios';
import { onMounted, ref } from 'vue';
import { useRouter } from 'vue-router';
const uc=useRouter()

onMounted(()=>{
    showw()
})

const da=ref([{
    "bingId": 0,
    "shuLiang": 0,
    "fangHao": "",
    "kong": 0,
    "fangCreateTime": "2025-05-19T13:55:09.3130179",
    "ksId": 1,
    "ksName": "",
    "ztName": ""
  }])

const can=ref({
    name:"",
    ksid:0
})


const showw=()=>{
    axios.get("/api/Fang/ShowFang",{params:can.value}).then(res=>{
        da.value=res.data
    })
}


onMounted(()=>{
    bang()
})

//绑定的m
const ba=ref([{
    "kId": 0,
    "ksName": "",
    "ksCount": 0,
    "ksMiaoShu": "",
    "ksCreateTime": "2025-05-19T11:29:32.2299346",
    "ksIsDel": false
  }])

  //绑定
  const bang=()=>{
    axios.get("/api/YiS/BangKs").then(res=>{
        ba.value=res.data;
    })
  }

  //查询
  const cha=()=>{
    showw()
  }

  //修改状态
  const gai=(x:any)=>{
      axios.get("/api/Fang/GaiZt",{params:{id:x}}).then(res=>{
          if(res.data>0){
            alert("状态修改成功");
            showw();
          }else{
            alert("状态修改失败")
          }
      })
  }
</script>

<style scoped>

</style>